MDriven administrative database tables

New 2024-02-18: Use MDrivenServer to create the admin tables instead of manually as described below

This is described in this video: PostgreSQL Database Reversing With MDriven - showing composite keys

MDriven administrative database tables 1708287873349.png

Manual Process

When you create a database from a model, these administrative tables will be added automatically for you.

However, when reversing an existing database to a model - and then wanting to use the model just like any another MDriven Model, you may find that you need to add these manually.

Below is the script and explanation of what the table is for:

Table name PostgreSQL
ECO_ID This is the cursor of the default internal key assigned to objects saved with the default persistence mapper.

This table only has 1 row holding the next free identity for a new object

CREATE TABLE [dbo].[ECO_ID](

[PK] [int] NOT NULL,

[BOLD_ID] [int] NOT NULL,

CONSTRAINT [PK_ECO_ID] PRIMARY KEY CLUSTERED

(

[PK] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

CREATE TABLE eco_id (

    pk SERIAL primary key,

    bold_id INT NOT NULL

);

ECO_ORMAPPING This holds a text-blob with the OR-mapping in MDrivenFormat (xml). MDriven reads this upon evolve of database to figure out what we has changed compared to the current model.

After successfull evolve MDriven writes the updated OR-mapping to this column. The Table only holds 1 row

CREATE TABLE [dbo].[ECO_ORMAPPING](

[ID] [int] NOT NULL,

[ECO_ORMAPPING] [ntext] NOT NULL,

PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

CREATE TABLE eco_ormapping (

id SERIAL PRIMARY KEY, eco_ormapping TEXT NOT NULL );

ECO_TABLES This table has one row per table that MDriven has created or taken ownership of in your database. CREATE TABLE [dbo].[ECO_TABLES](

[TABLENAME] [nvarchar](255) NOT NULL

) ON [PRIMARY]

GO

CREATE TABLE eco_tables (

tablename VARCHAR(255) NOT NULL );

ECO_TYPE This table holds the class names from your model along with an integer number unique to that type. If MDriven is instructed to write many types to the same table (OR-Parent-Mapping) MDriven figures out the runtime type by lookin the ECO_TYPE column of such a table - and the number will match a number in the ECO_TYPE table. CREATE TABLE [dbo].[ECO_TYPE](

[ECO_TYPE] [smallint] NOT NULL,

[CLASSNAME] [nvarchar](255) NOT NULL,

PRIMARY KEY CLUSTERED

(

[ECO_TYPE] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY]

GO

CREATE TABLE eco_type (

eco_type SMALLINT NOT NULL, classname VARCHAR(255) NOT NULL, PRIMARY KEY (eco_type) );

This page was edited 1 days ago on 11/20/2024. What links here